﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Collections;
using Microsoft.TeamFoundation.VersionControl.Client;
using Deployment.TeamFoundation.Entity;

namespace Deployment.TeamFoundation.Communication
{
    public class VersionControl : CommunicationBase
    {
        private static VersionControl instance;

        protected VersionControl() { }

        #region Singleton

        public static VersionControl Instance
        {
            get
            {
                if (instance == null)
                {
                    Mutex mutex = new Mutex();
                    mutex.WaitOne();

                    if (instance == null)
                        instance = new VersionControl();

                    mutex.Close();
                }
                return instance;
            }
        }

        #endregion Singleton

        /// <summary>
        /// Obtem o objeto de Controle de Versão
        /// </summary>
        /// <returns>Objeto de Controle de Versão</returns>
        public Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer GetVersionControlServer()
        {
            Microsoft.TeamFoundation.Client.TeamFoundationServer teamFoundationServer = TeamServer.Instance.GetSinacorTeamServer();
            Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer versionControlServer = (Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer)teamFoundationServer.GetService(typeof(Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer));
            return versionControlServer;
        }

    }
}
